package com.santu.edu.supporter.biz.order.wm.controller;

import com.santu.edu.supporter.biz.order.wm.pojo.dto.WmOrderDTO;
import com.santu.edu.supporter.biz.order.wm.pojo.params.WmOrderAddParam;
import com.santu.edu.supporter.biz.order.wm.pojo.params.WmOrderUpdateParam;
import com.santu.edu.supporter.biz.order.wm.service.WmOrderService;
import com.santu.edu.supporter.util.PageData;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @author luoyaoqi
 * @createTime 2024/2/22
 * @description
 */
@RestController
@Validated
@RequiredArgsConstructor
@RequestMapping("wm")
public class WmOrderController {

    private final WmOrderService wmOrderService;


    @PostMapping("add")
    public Boolean addOrder(@RequestBody @Valid WmOrderAddParam addParam) {
        return wmOrderService.addOrder(addParam);
    }

    @PostMapping("update")
    public Boolean updateOrder(@RequestBody @Valid WmOrderUpdateParam updateParam) {
        return wmOrderService.updateOrder(updateParam);
    }

    @PostMapping("cancel")
    public Boolean cancelOrder(@Param("orderId不能为空") String orderId) {
        return wmOrderService.cancelOrder(orderId);
    }

    @GetMapping("get/by/orderCode")
    public PageData<WmOrderDTO> getBuildingsList(@NotBlank(message = "schoolId不能为空")
                                                 String schoolId,
                                                 String userId,
                                                 Integer orderType,
                                                 int page,
                                                 int size) {
        return wmOrderService.getOrderList(schoolId, userId, orderType, page, size);
    }
}
